#!/bin/bash

path=`pwd`
config=$path/config
bin=$path/bin
python_config=$config/python
python=$bin/python

echo "开始安装python安装插件所需工具"
source $python/rely.sh

findConfig(){
	list=`ls $1`
	noPipInstall=true #安装完成要上锁，节约时间和空间成本
	for i in $list
	do
		if [ "$i" = "pyproject.toml" ] && [ $noPipInstall ];then
			echo "正在使用poetry安装$1/$i"
			cd $1
			poetry install
			cd $path
			noPipInstall=false
		elif [ "$i" = "requirements.txt" ] && [ $noPipInstall ];then
			echo "正在使用poetry run pip安装$1/$i"
			cd $1
			poetry run pip install -r requirements.txt -i https://mirrors.bfsu.edu.cn/pypi/web/simple
			cd $path
			noPipInstall=false
		elif [ -d $1/$i ];then
			findConfig $1/$i
		fi
	done
}
findConfig $path/gsuid_core

pip install -r ./gsuid_bot/gsuid_bot/plugins/GenshinUID/requirements.txt

for plugin in `cat $config/python/rely.txt`
do
	pipx install $plugin
done

cd gsuid_bot
pip install nonebot2[fastapi]
pip install nonebot2[httpx]
pip install nonebot2[websockets]
pip install nonebot-adapter-onebot
pip install nonebot-adapter-qqguild
pip install nonebot-plugin-gocqhttp
pip install nonebot-plugin-status
cd $path









